{
sort $isid_vars 
capture drop sample
gen sample=(S_pds==1 & n_ud==1) 		
	
*clonevar ln_mu_sbjo=ln_mu_o_B

label var D_sourcing "\$Relational^D_b\$" 
label var S_sourcing "\$Relational_b\$" 

eststo clear
eststo: reghdfe ln_lead_win S_sourcing    ///
ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 signatory ln_q_b_all age_buy_month   ln_q_sbjo ln_p_inpf_sbjo   ///
if sample==1 , ///
abs(gr_sjt top_dest_b cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace  
  
eststo: reghdfe ln_lead_win i1.D_sourcing    ///
ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 signatory ln_q_b_all age_buy_month   ln_q_sbjo ln_p_inpf_sbjo   ///
if sample==1 , ///
abs(gr_sjt top_dest_b cohort_b ) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace  

eststo: reghdfe ln_mu_sbjo ln_lead_win S_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month signatory  ///
 ln_q_b_all age_buy_month     ln_q_sbjo ln_p_inpf_sbjo  ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace     
  
eststo: reghdfe ln_mu_sbjo ln_lead_win i1.D_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month signatory  ///
 ln_q_b_all age_buy_month     ln_q_sbjo ln_p_inpf_sbjo  ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="OLS", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace     

esttab using "${tables}\TableC8.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
  title("Sourcing and Reliability in Delivery" \label{Delivery}) /// 
  drop(signatory ln_q_b_all age_buy_months  ln_q_sbjo ln_p_inpf_sbjo ln_q_sb_all sh_s_b sh_b_s age_buysel_months _cons) order(S_sourcing 1.D_sourcing ln_lead_win ) /// 
  stats(FE  CTRL r2   N   , fmt( %~#s   %~#s  2 %12.0fc  )  ///
  labels("FEs" "Controls" `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  
}
